<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <script src="https://unpkg.com/vue@next"></script>
  <style>
    .v-enter-from,.v-leave-to{
      opacity: 0;
    }
    .v-enter-active,.v-leave-active{
      transition: opacity 1s ease-in;
    }
    .v-enter-to,.v-leave-from{
      opacity: 1;
    }
    
  </style>
</head>

<body>
  <div id="root"></div>
  <script>
    
    const app = Vue.createApp({
      data(){
        return{ show:false}
      },
      methods:{
        click(){
          this.show=!this.show
        }
      },
    
      template:
      `<transition mode="out-in" appear>
        <div v-if="show">hello</div>
        <div v-else="show">world</div>
       </transition>  
       <button @click="click">切换</button>`
    });

    app.component('', {
      template:``
    });
   
    const vm = app.mount('#root');
  </script>
</body>

</html>